---
title: CockroachDB
header: Official Drivers
layout: ../../../layouts/MainLayout.astro
---

# CockroachDB Start Guide

> Remember: CockroachDB supports the PostgreSQL wire protocol. We use the same driver to connect for both Cockroach and PostgreSQL.

## 1. Connections

import RenderConnectionOptions from '../../../components/RenderConnectionOptions.tsx';

Connection example:

```json
{
  "name": "Cockroach",
  "server": "localhost",
  "driver": "CockroachDB",
  "port": 26257,
  "database": "test_db",
  "username": "root",
  "askForPassword": false,
  "password": "root",
  "connectionTimeout": 15
}
```

### 1.1 Specific Options

CockroachDB driver specific options can be passed using `pgOptions` settings.

```json
{
  "name": "Cockroach",
  "server": "localhost",
  "driver": "CockroachDB",
  "port": 26257,
  "database": "test_db",
  "username": "root",
  "askForPassword": false,
  "password": "root",
  "connectionTimeout": 15,
  "pgOptions": {
    ... // options
  }
}
```

You can use any options defined in https://node-postgres.com/features/connecting#programmatic in `pgOptions`.

They will be passed to the pool constructor directly. See https://github.com/mtxr/vscode-sqltools/blob/master/packages/core/driver/pgsql/index.ts .

### 1.2 Alternative Connection Strings

ConnectionStrings or connectionURIs are supported as defined in `node-postgres` library. See [Connection URI](https://node-postgres.com/features/connecting#connection-uri) for more information.

Using connectionURI for previous example:

```json
{
  "name": "Cockroach",
  "server": "localhost",
  "driver": "CockroachDB",
  "connectString": "postgresql://root:root@localhost:26257/test_db",
  "askForPassword": false,
  "connectionTimeout": 15
}
```

<RenderConnectionOptions
  client:only="react"
  exclude={['mysqlOptions', 'oracleOptions', 'socketPath', 'mssqlOptions', 'icons', 'domain']}
/>
